function refreshForms(type) {
    $('.table:first').bootstrapTable('refresh', {url: '/record/page?type=' + type});
}


$('.table:first').bootstrapTable({
    classes: '',
    locale: 'zh-CN',
    url: '/record/page',
    theadClasses: 'text-warning',
    pagination: true,
    pageSize: 5,
    sidePagination: "server",
    columns: [
        {field: 'id', title: '序号', sortable: true, align: 'center'},
        {field: 'goodsName', title: '货物名称', align: 'center'},
        {
            field: 'type', title: '类型', align: 'center', formatter: function (value, row, index) {
                return value == 1 ? '出库' : '入库';
            }
        },
        {field: 'sum', title: '数量', align: 'center'},
        {field: 'userName', title: '用户名称', align: 'center'}
    ],
    responseHandler: function (response) {
        return response.data;
    }
});

$('.table:last').bootstrapTable({
    classes: '',
    locale: 'zh-CN',
    uniqueId: "id",
    idField: "id",
    editable: true,
    theadClasses: 'text-warning',
    url: '/goods/page',
    pagination: true,
    pageSize: 5,
    sidePagination: "server",
    columns: [
        {field: 'id', title: 'id', sortable: true},
        {field: 'name', title: '物品名称'},
        {field: 'amount', title: '剩余数量'}
    ],
    responseHandler: function (response) {
        return response.data;
    }
});

initializer = {
    initDashboardPageCharts: function () {
        if ($('#dailySalesChart').length != 0 || $('#completedTasksChart').length != 0 || $('#websiteViewsChart').length != 0) {
            /* ----------==========     Daily Sales Chart initialization    ==========---------- */

            $.ajax({
                url: '/record/statistic/1',
                type: 'GET',
                success: function (response) {
                    let data = response.data;
                    dataDailySalesChart = {
                        labels: data.keys,
                        series: [
                            data.values
                        ]
                    };
                    optionsDailySalesChart = {
                        lineSmooth: Chartist.Interpolation.cardinal({
                            tension: 0
                        }),
                        low: 0,
                        high: 4500, // creative tim: we recommend you to set the high sa the biggest value + something for a better look
                        chartPadding: {
                            top: 0,
                            right: 0,
                            bottom: 0,
                            left: 0
                        },
                    }
                    var dailySalesChart = new Chartist.Line('#dailySalesChart', dataDailySalesChart, optionsDailySalesChart);

                    md.startAnimationForLineChart(dailySalesChart);
                }
            })


            $.ajax({
                url: '/record/statistic/2',
                type: 'GET',
                success: function (response) {
                    let data = response.data;


                    dataCompletedTasksChart = {
                        labels: data.keys,
                        series: [
                            data.values
                        ]
                    };


                    optionsCompletedTasksChart = {
                        lineSmooth: Chartist.Interpolation.cardinal({
                            tension: 0
                        }),
                        low: 0,
                        high: 4500, // creative tim: we recommend you to set the high sa the biggest value + something for a better look
                        chartPadding: {
                            top: 0,
                            right: 0,
                            bottom: 0,
                            left: 0
                        }
                    }
                    var completedTasksChart = new Chartist.Line('#completedTasksChart', dataCompletedTasksChart, optionsCompletedTasksChart);

                    // start animation for the Completed Tasks Chart - Line Chart
                    md.startAnimationForLineChart(completedTasksChart);
                }
            })


            $.ajax({
                url: '/goods/statistic',
                type: 'GET',
                success: function (response) {
                    let data = response.data;

                    var dataWebsiteViewsChart = {
                        labels: data.keys,
                        series: [
                            data.values
                        ]
                    };
                    var optionsWebsiteViewsChart = {
                        axisX: {
                            showGrid: false
                        },
                        low: 0,
                        high: 10000,
                        chartPadding: {
                            top: 0,
                            right: 5,
                            bottom: 0,
                            left: 0
                        }
                    };
                    var responsiveOptions = [
                        ['screen and (max-width: 640px)', {
                            seriesBarDistance: 5,
                            axisX: {
                                labelInterpolationFnc: function (value) {
                                    return value[0];
                                }
                            }
                        }]
                    ];
                    var websiteViewsChart = Chartist.Bar('#websiteViewsChart', dataWebsiteViewsChart, optionsWebsiteViewsChart, responsiveOptions);

                    //start animation for the Emails Subscription Chart
                    md.startAnimationForBarChart(websiteViewsChart);


                }
            })
        }
    },

}
